#include "ak8975.h"

vs16 AK8975_Data[3];

void AK8975_Cal(void)
{
	static u8 begin_8975=1;
	
	if(begin_8975)
	{
		begin_8975 = 0;
		u8 data = 1;
		ANO_TC_I2C1_Write_Buf(0x18,0x0a,1,&data);
	}
	else
	{
		u8 temp,data_temp[6];
		ANO_TC_I2C1_Read_Buf(0x18,0x02,1,&temp);
		if(temp==1)
		{
			ANO_TC_I2C1_Read_Buf(0x18,0x03,6,data_temp);
			AK8975_Data[0]=data_temp[1]<<8 | data_temp[0];
			AK8975_Data[1]=data_temp[3]<<8 | data_temp[2];
			AK8975_Data[2]=data_temp[5]<<8 | data_temp[4];
			u8 data = 1;
			ANO_TC_I2C1_Write_Buf(0x18,0x0a,1,&data);
		}
	}
}
